<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;

/**
 * App\Models\SettingHomeImage
 *
 * @property int $id
 * @property string $img_name 轮播图的背景图名称
 * @property string $img_url 首页轮播图的图片地址
 * @property string $url_set 图片的点击效果,链接
 * @property int $is_show 当前轮播图图片是否显示(0:不显示 1 显示)
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SettingHomeImage newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SettingHomeImage newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SettingHomeImage query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SettingHomeImage whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SettingHomeImage whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SettingHomeImage whereImgName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SettingHomeImage whereImgUrl($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SettingHomeImage whereIsShow($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SettingHomeImage whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SettingHomeImage whereUrlSet($value)
 * @mixin \Eloquent
 */
class SettingHomeImage extends Model
{
    //数据库初始化数据个数
    const INIT_DATA_NUMBER = 4;

    protected $guarded = ['id'];

    public static function deleteImage($id,$update_img_url){
        $img_url = self::where('id',$id)->value('img_url');
        if($img_url != $update_img_url){
            $a = Storage::disk('oss')->delete($img_url);
        }
    }

}
